package cmd

import (
	l4g "github.com/alecthomas/log4go"
	"os/exec"
)

type DBconfig struct {
	User string
	Password string
}


func flushLogs()  {
	l4g.Info("开始执行 ******* 数据库 binlog 清理")
	dBconfig:=config.DBconfig
	args := []string{
		"-u"+dBconfig.User,
		"-p"+dBconfig.Password,
		"-e\"flush logs;\"",
	}
	cmd := exec.Command("mysql", args...)
	out, err := cmd.CombinedOutput()
	if err != nil {
		l4g.Error("执行清理出现问题 %s",err,out)
	}else {
		l4g.Info(out)
	}
}

func init()  {
	c.AddFun("MysqlflushLogs",flushLogs)
}